<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let sum = 1000;
        let flag = true;
        while (flag) {
            let key = prompt('请选择您的操作 1.取款 2.存款 3.查询余额 4.退出');
            switch (key) {
                case '1':
                    let money = +prompt('请输入取款金额');
                    sum - money < 0 ? alert('余额不足') : sum -= money
                    break;
                case '2':
                    let money1 = +prompt('请输入存款金额');
                    sum += money1
                    alert('存款成功');
                    break;
                case '3':
                    alert(`余额为：${sum}`);
                    break;
                case '4':
                    flag = false;
                    alert('退出成功');
                    break;
                default:
                    alert('请选择正确的操作');
            }
        }
    </script>
</body>

</html>